//
//  UpChildOneView.m
//  FoodCorner
//
//  Created by lanou3g on 16/2/27.
//  Copyright © 2016年 zhangchao. All rights reserved.
//

#import "UpChildOneView.h"
#define WSelf self.frame.size.width
#define HSelf self.frame.size.height
@implementation UpChildOneView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self andSubview];
    }
    return self;
}
- (void)andSubview{
    
   
    self.imageView = [[UIImageView alloc]init];
    
//    self.imageView.backgroundColor = [UIColor blueColor];
    
    self.imageView.image = [UIImage imageNamed:@"1.jpg"];
    self.imageView.layer.cornerRadius = 40;
    self.imageView.layer.masksToBounds = YES;
    //设置label button大小
    
    self.labOne = [[UILabel alloc]init];
    self.labOne.text = @"手机用户xxx";
     self.labTwo = [[UILabel alloc]init];
   
    self.labTwo.text = @"12";
    self.labTwo.textColor = [UIColor redColor];
    
    self.buttonOne = [UIButton buttonWithType:UIButtonTypeCustom];
    [_buttonOne setTitle:@"关注" forState:UIControlStateNormal];
   
    
    self.labThree = [[UILabel alloc]init];
    
    self.labThree.text = @"45";
    self.labThree.textColor = [UIColor redColor];
    
    self.buttonTwo = [UIButton buttonWithType:UIButtonTypeCustom];
     [_buttonTwo setTitle:@"粉丝" forState:UIControlStateNormal];
    
    self.labFour = [[UILabel alloc]init];
    
    self.labFour.text = @"2016-02-26加入";
    
    [self addSubview:_buttonOne];
    [self addSubview:_buttonTwo];
    [self addSubview:_labOne];
    [self addSubview:_labTwo];
    [self addSubview:_labThree];
    [self addSubview:_labFour];
    [self addSubview:_imageView];
    
    
    
}
- (void)layoutSubviews{
    
    [super layoutSubviews];
    
//        CGFloat selfW = self.frame.size.width;
//        CGFloat selfH = self.frame.size.height;
//        CGFloat margin = 5;
    //
    //
    //    CGFloat imaH = selfH *0.6;
    //    CGFloat imaX = margin;
    //    CGFloat imaY = ((selfH - imaH)-margin)*0.5;
    //    CGFloat imaW = selfW *0.25;
    //    self.imageView.frame = CGRectMake(imaX,imaY,imaW,imaH);
    //
    //    //lab的frame
    //    CGFloat imaH = selfH *0.6;
    //    CGFloat imaX = margin;
    //    CGFloat imaY = ((selfH - imaH)-margin)*0.5;
    //    CGFloat imaW = selfW *0.25;
    
//    self.imageView.frame = CGRectMake(imaX, imaY, imaW, imaH);
    self.imageView.frame = CGRectMake(HSelf *0.1,HSelf *0.25, HSelf *0.5, HSelf *0.5);
    self.labOne.frame = CGRectMake(CGRectGetMaxX(self.imageView.frame) + 10, HSelf *0.25, self.imageView.frame.size.width *3, (self.imageView.frame.size.height - 10)*0.33);
//    self.labOne.backgroundColor = [UIColor blackColor];

    self.labTwo.frame = CGRectMake(CGRectGetMaxX(self.imageView.frame) + 10, CGRectGetMaxY(self.labOne.frame)+5, (self.imageView.frame.size.height - 10)*0.33, (self.imageView.frame.size.height - 10)*0.33);
//     self.labTwo.backgroundColor = [UIColor blackColor];
    
    self.buttonOne.frame = CGRectMake(CGRectGetMaxX(self.labTwo.frame) + 5, CGRectGetMaxY(self.labOne.frame)+5, (self.imageView.frame.size.height - 10)*0.33 *2, (self.imageView.frame.size.height - 10)*0.33);
//    self.buttonOne.backgroundColor = [UIColor blackColor];
    
    self.labThree.frame = CGRectMake(CGRectGetMaxX(self.buttonOne.frame) + 5, CGRectGetMaxY(self.labOne.frame)+5, (self.imageView.frame.size.height - 10)*0.33, (self.imageView.frame.size.height - 10)*0.33);
//    self.labThree.backgroundColor = [UIColor blackColor];
    
    
     self.buttonTwo.frame = CGRectMake(CGRectGetMaxX(self.labThree.frame)+5, CGRectGetMaxY(self.labOne.frame)+5, (self.imageView.frame.size.height - 10)*0.33 *2,(self.imageView.frame.size.height - 10)*0.33);
    
//    self.buttonTwo.backgroundColor = [UIColor blackColor];
    
    
    self.labFour.frame = CGRectMake(CGRectGetMaxX(self.imageView.frame)+10, CGRectGetMaxY(self.labThree.frame)+5, self.imageView.frame.size.width *3, (self.imageView.frame.size.height - 10)*0.33);
    
//    self.labFour.backgroundColor = [UIColor blackColor];
    
}

@end
